package com.cx.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: Zhou wei
 * @create: 2020/5/25 9:42
 */
public class DateFormat {
    /**
     * 将日期转换为指定格式返回
     * @param date
     * @param format
     * @return
     */
    public static String dateFormat(Date date,String format){
        if (date == null){
            return "";
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        String dateString = simpleDateFormat.format(date);
        return dateString;

    }

    public static String dateFormat1(Long str,String format){
        if (str == 0){
            return "";
        }

        Date date  = new Date(str);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
        String dateString = simpleDateFormat.format(date);
        return dateString;

    }
}
